<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<md-step label="Doc" md-complete="$ctrl.parent.vm.stepData[3].data.completed" ng-disabled="$ctrl.parent.vm.stepProgress < 4">
  <md-step-body>
    <md-tabs md-dynamic-height md-border-bottom flex layout-padding class="gv-creation-content">
      <md-tab label="Import file">
        <div class="import-file-drop-box">
          <input type="file" filecontent="$parent.newApiPageFile.content" filename="$parent.newApiPageFile.name" />
        </div>
        <md-content class="gv-creation-pages-content">
          <md-table-container ng-if="$ctrl.parent.hasPage()" style="margin-top: 20px">
            <table md-table style="border: none">
              <thead md-head style="background: #fff">
                <tr md-row>
                  <th md-column>Page name</th>
                  <th md-column>File name</th>
                  <th md-column></th>
                </tr>
              </thead>
              <tbody md-body>
                <tr md-row ng-repeat="page in $ctrl.parent.api.pages" style="background: #fff">
                  <td md-cell><input type="text" ng-model="page.name" placeholder="Page name" /></td>
                  <td md-cell>{{page.fileName}}</td>
                  <td md-cell ng-click="$event.stopPropagation()">
                    <div layout="row" layout-align="end center">
                      <span>
                        <md-tooltip md-direction="top">delete</md-tooltip>
                        <ng-md-icon icon="delete" ng-click="$ctrl.parent.removePage(page)" aria-label="delete-page"></ng-md-icon>
                      </span>
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </md-table-container>
        </md-content>
      </md-tab>
    </md-tabs>

    <md-step-actions layout="row">
      <div flex>
        <md-button ng-click="$ctrl.parent.moveToPreviousStep()">PREVIOUS</md-button>
      </div>
      <div flex layout="row" layout-align="end top">
        <md-button
          ng-if="$ctrl.parent.vm.stepData[3].optional"
          ng-click="$ctrl.parent.skipDocumentation(); $ctrl.parent.submitCurrentStep($ctrl.parent.vm.stepData[3].data)"
          >SKIP
        </md-button>
        <md-button
          ng-disabled="!$ctrl.parent.hasPage()"
          ng-click="$ctrl.parent.selectDocumentation(); $ctrl.parent.submitCurrentStep($ctrl.parent.vm.stepData[3].data)"
          >NEXT
        </md-button>
      </div>
    </md-step-actions>
  </md-step-body>
</md-step>
